package com.example.interview.no0201.solution;

import com.example.interview.no0201.ListNode;
import com.example.interview.no0201.Solution;

/**
 * @Description 解答接口-移除重复节点
 * @ClassName WhileSolutionImpl
 * @Author Administrator
 * @Date 2020/7/9 14:43
 * @Version 1.0.0
 */
public class WhileSolutionImpl implements Solution {
    @Override
    public ListNode removeDuplicateNodes(ListNode head) {
        ListNode ob = head;
        while (ob != null) {
            ListNode oc = ob;
            while (oc.next != null) {
                if (oc.next.val == ob.val) {
                    oc.next = oc.next.next;
                } else {
                    oc = oc.next;
                }
            }
            ob = ob.next;
        }
        return head;
    }
}
